<?php
namespace app\common\traits;

abstract class Singleton{
	private static $instance=array();

	public static function instance(...$arg){
		$obj=static::class;
		if(!isset(self::$instance[$obj])){
           self::$instance[$obj]=new $obj(...$arg);
		}
		return self::$instance[$obj];
	}
	private function __construct(...$arg){
		method_exists($this,'onConstruct')&&$this->onConstruct(...$arg);
	}

	private function __clone(){}
}